package com.kude.manager.support;

public class OrderByCondition extends AbstractCondition {
	
	private String orderByCondition="";
	public static final String DESC="desc";//降序
	public static final String ASC="asc";//升序
	
	public class KeyOrder{
		private String key;
		private String order;
		public KeyOrder(String key,String order) {
			this.key=key;
			this.order=order;
		}
		
		public String encode() {
			return key+" "+order;
		}
	}
	
	public OrderByCondition(KeyOrder... keyOrders) {
		for (KeyOrder keyOrder : keyOrders) {
			if (orderByCondition.equals("")) {
				orderByCondition += keyOrder.encode();
			} else {
				orderByCondition += "," + keyOrder.encode();
			}
		}
	}

	@Override
	String toSql() {
		return orderByCondition;
	}

}
